package Levels;

import org.andengine.entity.scene.background.Background;

import Parts.HexagonTile;
import Parts.Player;
import Parts.HexagonTile.HexagonState;
import Units.*;
import Utils.Array;
import Utils.Vector2;
import nl.hro.mgdd.team4.raidersofhexagoniland.Scenes.LevelBaseScene;
import nl.hro.mgdd.team4.raidersofhexagoniland.Scenes.SceneManager;

public class W1Level2 extends LevelBaseScene{
	
	public W1Level2(){
		SceneManager._player = new Player(2, 3, 3);
		_origin = new Vector2(0f, 22f);
		_map = new HexagonTile[3][4];
		//Array<Unit>a = new Array<Unit>(new Unit[]{new Archer(true), new Swordman(true), new Spearman(true)});
		_map[1][3] = new HexagonTile(new Vector2(1, 3), HexagonState.StartTile, null, 13);
		_map[0][1] = new HexagonTile(new Vector2(0, 1), HexagonState.Occupied, new Array<Unit>(new Unit[]{new Spearman()}), 1);
		_map[0][2] = new HexagonTile(new Vector2(0, 2), HexagonState.Occupied, new Array<Unit>(new Unit[]{new Spearman(), new Spearman()}), 2);
		_map[2][2] = new HexagonTile(new Vector2(2, 2), HexagonState.Occupied, new Array<Unit>(new Unit[]{new Archer(), new Archer()}), 22);
		_map[2][3] = new HexagonTile(new Vector2(2, 3), HexagonState.Occupied, new Array<Unit>(new Unit[]{new Archer()}), 23);
		_map[1][1] = new HexagonTile(new Vector2(1, 1), HexagonState.Occupied, new Array<Unit>(new Unit[]{new Archer(), new Spearman(), new Swordman()}), 11);
		_map[1][0] = new HexagonTile(new Vector2(1, 0), HexagonState.FinishTile, null, 10);

		int eSword = 0;
		int eSpear = 0;
		int eBow = 0;
		for (int x = 0; x < getMapWidth(); x++)
			for (int y = 0; y < getMapHeight(); y++)
				if (_map[x][y] != null) {
					if (_map[x][y].getUnitCount() != 0) {
						for (Unit u : _map[x][y].getUnits()) {
							if (u.getTag() == 999)
								eBow++;
							if (u.getTag() == 998)
								eSpear++;
							if (u.getTag() == 997)
								eSword++;
						}
					}
					_tiles.add(_map[x][y]);
				}

		SceneManager._enemy = new Player(eSword, eBow, eSpear);
		setBackground(new Background(0.5f, 0.5f, 0.5f));
		loadResources();
	}

	@Override
	public int getMapWidth(){
		return 3;
	}
	
	@Override 
	public int getMapHeight(){
		return 4;
	}
}
